package com.iqiyi.pps.epg.core.dao.auth;

import com.iqiyi.pps.epg.core.dao.base.HibernateDao;
import com.iqiyi.pps.epg.core.model.auth.Resource;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class ResourceDao extends HibernateDao<Resource, Long> {
	public static final String QUERY_BY_RESOURCETYPE = "from Resource r left join fetch r.authorities WHERE r.type=? ORDER BY r.priority ASC";

	@SuppressWarnings("unchecked")
	public List<Resource> getUrlResourceWithAuthorities() {
		return distinct(createQuery(QUERY_BY_RESOURCETYPE, Resource.TYPE_URL)).list();
	}
}
